/**
 * 
 */
package com.feonix.complat.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.feonix.common.BaseInfo;
import com.feonix.common.interceptor.BaseInterceptor;
import com.feonix.common.listener.UserSessionInfo;

/**
 * @CopyRight (c)1993-2017
 * @Project m-complat-controller
 * @Comments 请输入该类的描述
 * @NameSpace com.feonix.complat.interceptor
 * @Author Feonixzw
 * @CreateDate 2017年11月9日
 */
public class LoginCheckInterceptor extends BaseInterceptor {

	/* (non-Javadoc)
	 * @see com.feonix.common.interceptor.BaseInterceptor#before(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object)
	 */
	@Override
	public boolean before(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
			Object object) {
		if (UserSessionInfo.getCurrentUser() == null) {
			try {
				httpServletResponse.sendRedirect(BaseInfo.getContextPath() + "/error/logintimeout.do");
			} catch (Exception e) {
				logger.error("sendRedirect error", e);
			}
			return false;
		}
		return true;
	}

	/* (non-Javadoc)
	 * @see com.feonix.common.interceptor.BaseInterceptor#after(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.web.servlet.ModelAndView)
	 */
	@Override
	public void after(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object,
			ModelAndView modelAndView) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see com.feonix.common.interceptor.BaseInterceptor#complete(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, java.lang.Exception)
	 */
	@Override
	public void complete(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object,
			Exception exception) {
		// TODO Auto-generated method stub

	}

}
